package com.ling.brushes
{
	import com.ling.brushes.view.BaseGridBrush;
	import com.ling.brushes.view.DoubleJellyBrush;
	import com.ling.brushes.view.EmptyBrush;
	import com.ling.brushes.view.JellyBrush;
	import com.ling.brushes.view.NormalBrush;
	import com.ling.brushes.view.StoneBrush;
	import com.ling.brushes.view.WireBrush;
	
	import flash.events.MouseEvent;
	
	import spark.components.Panel;

	public class BrushControl
	{
		private var _brush:BaseGridBrush;
		private var brushArr:Array;
		
		public function BrushControl(app:LingEditor)
		{
			var group:Panel = app.brushGroup;
			brushArr = [new EmptyBrush,new WireBrush,new StoneBrush,new DoubleJellyBrush,new JellyBrush,new NormalBrush];
			
			for each(var i:BaseGridBrush in brushArr)
			{
				group.addElementAt(i,1);
				i.addEventListener(MouseEvent.CLICK,clickBrush);
			}
		}
		
		private function clickBrush(event:MouseEvent):void
		{
			for each(var i:BaseGridBrush in brushArr)
			{
				i.selected = false;
			}
			_brush = event.currentTarget as BaseGridBrush;
			_brush.selected = true;
		}
		
		public function get brush():BaseGridBrush
		{
			return _brush;
		}
	}
}